import 'package:flutter/material.dart';

class ContactWidget extends StatelessWidget {
  
  @override
  Widget build(BuildContext context) {
    List<Widget> list = new List<Widget>();
    List<String> names = <String>[
      "新的朋友",
      "群聊",
      "标签",
      "公众号"
    ];
    List<String> icons = <String>[
      'assets/icons/new_friends.png',
      'assets/icons/group_chat.png',
      'assets/icons/tag.png',
      'assets/icons/public_account.png'
    ];
    for (int i=0; i<4; i++) {
      list.add(
        SizedBox(
          width: double.infinity,
          height: 46,
          child: Container(
              //color: Color(0xFFFFFFFF),
              color: Colors.white,
              child: Container(
                child: ConstrainedBox(
                  constraints: BoxConstraints.expand(),
                  child: Stack(
                    alignment: Alignment.centerLeft,
                    children: <Widget>[
                      // 头像
                      Positioned(
                        top:0,
                        left: 6,
                        width: 38,
                        height: 38,
                        child: Container(
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(3),
                            image: DecorationImage(
                              image: AssetImage(icons[i]),
                              fit: BoxFit.cover
                            )
                          ),
                        ),
                      ),
                      // 昵称
                      Positioned(
                        top:10,
                        left: 50,
                        child: Text(names[i], style: TextStyle(fontSize: 16, color: Color(0xFF060606)),),
                      ),
                      //分割线
                      Positioned(
                        bottom:0,
                        left: 61,
                        width: 300,
                        child: Divider(
                            color: Colors.grey[350],
                          )
                      )
                    ],
                  ),
                ),
              ),
            ),
        )
      );
    }

    // 字母分隔栏
    list.add(
      SizedBox(
        width: double.infinity,
        height: 32,
        child: Container(
            color: Color(0xFFEDEDED),
            child: Stack(
              alignment: Alignment.centerLeft,
              children: <Widget>[
                Positioned(
                  left: 16,
                  child: Text("C", style: TextStyle(color: Color(0xFF858585), fontWeight: FontWeight.bold),),
                )
              ],
            )
          ),
      )
    );

    List<String> contact_name = <String>[
      "陈敏娜",
      "陈耀栋",
      "Christ",
      "陈建",
      "陈道金",
      "程简"
    ];

    List<String> contact_icon = <String>[
      'assets/images/head_chenminna.jpg',
      'assets/images/head_chenyaodong.jpg',
      'assets/images/head_who.jpg',
      'assets/images/head_chenjian.jpg',
      'assets/images/head_chendj.jpg',
      'assets/images/head_chengjian.jpg',
    ];

    int contact_count = contact_name.length;

    // 联系人
    for (int i=0; i<contact_count; i++) {
      list.add(
        SizedBox(
            width: double.infinity,
            height: 50.0,
            child: Container(
                color: Color(0xFFFFFFFF),
                child: Container(
                  child: ConstrainedBox(
                    constraints: BoxConstraints.expand(),
                    child: Stack(
                      alignment: Alignment.centerLeft,
                      children: <Widget>[
                        // 头像
                        Positioned(
                          top:6,
                          left: 16,
                          width: 38,
                          height: 38,
                          child: Container(
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(6),
                              image: DecorationImage(
                                image: AssetImage(contact_icon[i]),
                                fit: BoxFit.cover
                              )
                            ),
                          ),
                        ),
                        // 昵称
                        Positioned(
                          top:12,
                          left: 66,
                          child: Text(contact_name[i], style: TextStyle(fontSize: 16, color: Color(0xFF060606)),),
                        ),
                        //分割线
                        Positioned(
                          top: 41,
                          left: 61,
                          width: 300,
                          child: Divider(
                              color: Colors.grey[350],
                            )
                        )
                      ],
                    ),
                  ),
                ),
              ),
          )
      );
    }

    return Scrollbar(
      child: ListView(
        padding: EdgeInsets.only(top: 4),
        children: list,
      ),
    );
  }
}